//引入express模块
const express = require("express");
//引入cors模块
const cors = require("cors");
//引入路由模块
const ubRouter = require("./router/ub");
//创建Web服务器
const app = express();

//解决跨域问题
app.use(cors({
  origin:[
    "http://localhost:8080",
    "http://127.0.0.1:8080",
    "http://localhost:8081",
    "http://127.0.0.1:8081",
    "http://localhost:8082",
    "http://127.0.0.1:8082"
  ],
  credentials:true  //要求允许携带cookie
}))
//托管静态资源public
app.use(express.static("./public"))

app.use(express.urlencoded({ extended:false }))
//挂载使用路由器ubRouter,并添加前缀 ub
app.use("/ub",ubRouter)

//设置端口号
app.listen(5556,()=>{ console.log("server runing...") });
